package com.novelastudios.utils
{
	/**
	 * @author John Bailey, NovelaStudios ©2010
	 */
	public class ArrayUtil
	{		
		///////////////////////////////////////////////////////////////////////////////
		//								PUBLIC METHODS
		///////////////////////////////////////////////////////////////////////////////
		/**
		 * Gives you the index of a specific item in an array.
		 *
		 * @param array The array you want to inspect for the item's index
		 * @param item 	The item you're wanting to know it's index
		 *
		 *  @return The index of the item within the array. If not found, -1 is returned.
		 * 
		 */		
		public static function getItemIndex(array:Array,item:*,strict:Boolean=true):Number
		{
			var currentItem:*;
			for( var i : Number = 0; i < array.length; ++i )
			{
				if(strict)
				{
					if(array[i] === item)
						return i;
				}
				else
				{
					if(array[i] == item)
						return i;
				}
			}
			return -1;
		}
		
		
		/**
		 * Whether or not a value (not key) is contained within the array. 
		 * 
		 * @param array The array you want to inspect for a particular value (not key)
		 * @param value The value you're wanting to determine is in the array
		 * 
		 * 
		 */		
		public static function hasValue(array:Array,value:*):Boolean
		{
			return getItemIndex(array,value,false) > -1 ? true : false;
		}
	}
}